<?php
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
    {
        exponent_flow_set(SYS_FLOW_PROTECTED,SYS_FLOW_ACTION);
        require_once(BASE."modules/formhelpermodule/formhelper.php");
        $formhelper=new formhelper("mailinglistmodule","_mail_manager_queue_title","_Manager_Email_Queue",$loc);
        $formhelper->setGridType(FORMHELPER_GRID_TYPE_DATAGRID);
        $formhelper->setGridOptions("height",500);
        $formhelper->setGridOptions("idField","id");
        $formhelper->setGridOptions("pagination",1);
        $formhelper->setGridOptions("pageNumber","1");
        $formhelper->setGridOptions("pageSize","20");
        $formhelper->setGridOptions("rownumbers","true");
        $formhelper->setGridOptions("singleSelect","true");
        $formhelper->setGridID("mail_queue");
        $formhelper->setInitCallback("TestGridCallback");
        $js=URL_FULL."modules/mailinglistmodule/js/Email_Queue.js";
        $formhelper->addJS($js);
        $formhelper->setColumnType(1);
        $formhelper->addColumn(array("field"=>"send_to","title"=>"Send To",'width'=>300));
        $formhelper->addColumn(array("field"=>"subject","title"=>"Subject",'width'=>300));
        $formhelper->addColumn(array("field"=>"content","title"=>"Content",'width'=>300));
        $formhelper->addColumn(array("field"=>"send_cc","title"=>"Send CC",'width'=>200));
        $formhelper->addColumn(array("field"=>"send_bcc","title"=>"Send BCC",'width'=>200));
        $formhelper->addColumn(array("field"=>"date_insert_formater","title"=>"Date Insert",'width'=>200));
        $formhelper->addColumn(array("field"=>"mail_status","title"=>"Mail Status",'width'=>100,'formatter'=>"function(value){if (value==0) return 'Not Send'; else if(value==1) return 'Has Been Send'; else return 'Error Send';}"));
        $formhelper->addColumn(array("field"=>"date_send_formater","title"=>"Date Send",'width'=>200,"sortable"=>"true"));
        $formhelper->addColumn(array("field"=>"error_log","title"=>"Error Log",'width'=>300));
        $link_param="/index.php?module=mailinglistmodule&action=manage_email_queue_json&src={$loc->src}&ajax_action=1";
        $formhelper->setURLDataStream($link_param);
        $formhelper->setGridOptions("onBeforeLoad","function(___form_onBeforeLoad");
        $toolbar_template=new template("mailinglistmodule","_Email_Manager_ToolbarHTML",$loc);
        $toolbar_template->register_permissions(array('administrate',"configure"),$loc);
        $toolbar_html=$toolbar_template->render();
        $formhelper->addToolbarHTML($toolbar_html);
        $formhelper->addToolbarStyle('height:50px');
        $formhelper->setPreInitJSCall("form_sysmail_preinit");
        $formhelper->register_permissions(array('administrate',"configure"),$loc);
        $formhelper->output();
    }
?>
